<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">

    <!-- 新 Bootstrap5 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/5.1.1/css/bootstrap.min.css">

    <!--  popper.min.js 用于弹窗、提示、下拉菜单 -->
    <script src="https://cdn.staticfile.net/popper.js/2.9.3/umd/popper.min.js"></script>

    <!-- 最新的 Bootstrap5 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.net/twitter-bootstrap/5.1.1/js/bootstrap.min.js"></script>

    <title>Title</title>
</head>
<body>

<div th:fragment="navbar">
    <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
        <div class="container-fluid">
            <a class="navbar-brand" th:href="@{/article/1}">Logo</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mynavbar">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="mynavbar">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/getuser}">个人资料</a>
                    </li>
                    <li class="nav-item" sec:authorize="hasAuthority('ROLE_vip')">
                        <a class="nav-link" href="javascript:void(0)">用户管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="javascript:void(0)">文章管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/backOfficeManagement}">后台管理</a>
                    </li>

                    <!-- Dropdown -->
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-bs-toggle="dropdown">
                            资源共享
                        </a>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" th:href="@{/upload}">上传</a>
                            <a class="dropdown-item" th:href="@{/download}">下载</a>
                        </div>
                    </li>
                </ul>

                <div sec:authorize="isAnonymous()">
                    <a class="nav-link" th:href="@{/login}">登录</a>
                </div>
                <div sec:authorize="isAuthenticated()">
                    <p style="color: #007bff">你好， <span sec:authentication="name"></span> </p>
                    <form th:action="@{/logout}" method="post">
                        <input class="nav-link" type="submit" th:value="注销">
                    </form>
                </div>
                <form th:action="@{/search}" method="get" class="mb-3">
                    <input type="text" name="query" placeholder="Search articles..." th:value="${query}" />
                    <button type="submit">Search</button>
                </form>
            </div>
        </div>
    </nav>
</div>
<div class="article wrapper">
    <h3 th:text="${article.title}"></h3>
    <p th:text="${article.content}"></p>
    <p>点击量: <span th:text="${article.clickCount}"></span></p>
    <p>点赞量: <span th:text="${article.likeCount}"></span></p>
    <form th:action="@{/article/like/{id}(id=${article.id})}" method="post">
        <button type="submit" class="btn btn-success">点赞</button>
    </form>
</div>


</body>
</html>